﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using BusinessObjects.BO_GetObjects;
using BussinessObjects;
using BusinessObjects;
using LibraryO2S;

public partial class controls_admin_ReferentNews : Pages_Base
{
    private DataTable objDT;
    protected void Page_Load(object sender, EventArgs e)
    {
        base.removeHGC(divMessage);
        if (!IsPostBack)
            loadData();
    }
    protected void loadData()
    {
        try
        {
            int c_id = 2;
            objDT = BO_Articles.SelectByCategory(c_id, base.Cur_page, base.Page_size);
            bindRepeater(rptNews, objDT, divMessage);
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
    protected void rptNews_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        try
        {
            string commandName = e.CommandName;
            if (commandName.Equals("del"))
            {
                BO_Articles.Delete(Convert.ToInt32(e.CommandArgument));
                divMessage.InnerHtml = O2S_Message.Success("Thông Báo", "Xóa thành công .");
            }
            loadData();
        }
        catch (Exception ex) { divMessage.InnerHtml = O2S_Message.Error("Lỗi", "Phát hiện lỗi: <br />" + ex.Message); }
    }
    protected void btnNew_Click(object sender, EventArgs e) { Response.Redirect("default.aspx?module=referentnewsadd"); }
}
